[PHP] Script looking for string in file breaks

Posted by Kel on Stack Overflow See other posts from Stack Overflow or by Kel
Published on 2010-06-14T14:19:24Z Indexed on 2010/06/14 14:22 UTC
Read the original article Hit count: 190

Filed under:
|
|

Hey guys. I'm running a script that looks for a specific term in a pdf file. Well, actually I'm reading the pdf file as a txt file and look for the term there. The script processes over 20k files. But, unexpectedly, the script breaks after it hits a file that is over 50mb long. It stops.

What could the reason be? Here's an excerpt of the script:

// Proceed if file exists
if(file_exists($sourcePath)){
    echo "file exists\n";
    if(filesize($sourcePath) > 0){
        echo "filesize is greater than 0\n";
        $pdfFile = fopen($sourcePath,"rb");
        $data = fread($pdfFile, filesize($sourcePath));
        fclose($pdfFile);

        // Search for string
        if(stripos($data,$searchFor)){
            echo "Success. encrypt found\r\n";
            fwrite($errorFileHandler,"Success. encrypt found\r\n");
        }else{
        .....
        }
      ...
      ...

What could be the problem?

© Stack Overflow or respective owner

Related posts about php

Related posts about pdf